package com.zbkj.front.controller;

import cn.hutool.core.date.DatePattern;
import com.zbkj.dal.base.result.CommonResult;
import com.zbkj.service.manager.ExpressManager;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.util.Collections;

@RestController
@RequestMapping("api/front/sys")
public class SysController {

    @Autowired
    private ExpressManager expressManager;

    @ApiOperation("获取系统当前时间")
    @GetMapping("/server-time")
    public CommonResult<String> time() {
        return CommonResult.success(LocalDateTime.now().format(DatePattern.NORM_DATETIME_FORMATTER));
    }

    @ApiOperation(value = "获取云打印电子面单", hidden = true)
    @GetMapping("/cloud-print-waybills")
    public CommonResult<?> cloudPrintWaybills(@RequestParam String expressNumber) {
        expressManager.printWayBills(Collections.singleton(expressNumber));
        return CommonResult.success();
    }
}
